import axios from './request'

const getCityList = () => {
  return new Promise(async resolve => {
    let city = {}
    const { body, status } = await axios.get('/area/city?level=1')
    if (status === 200) {
      //遍历处理数据
      body.forEach(e => {
        if (e.short[0] in city) {
          city[e.short[0]].push({
            label: e.label,
            short: e.short,
            value: e.value
          })
        } else {
          city[e.short[0]] = [e]
        }
      })
    }
    resolve(city)
  })
}
// getCityList().then(res => {
//   console.log(res)
// })
export { getCityList }
